﻿<?xml version="1.0" encoding="utf-8"?>
<Scenarios>
	<Scenario>
		<s>
			Start the app.
			<s p="2">
				It appears in system tray. It says it's up and running.
			</s>
		</s>
		<s>
			Right click and context menu comes. Menu has 2 options. Open. Exit.
		</s>
		<s>
			Click on open and a win form is launched.
		</s>
		<s>
			The form contains current battery info.
			The form contains previous battery info in graph form.
			Export to CVS for more analysis (beta feature only)
			Predictions
		</s>
		<s>
			The graph contains past battery info data
			<s>
				This data consists of time stamp, battery %age, Battery current status (chargin or discharging)
			</s>
			<s p="2">
				Contains CPU history. Ram history, HDD history, Network history. This is to fighre out LOAD pattern
			</s>
		</s>
		<s>
			Predictions contain
				Time left to full charge (if charging).
				Time left to full discharge (if discharging)
		</s>

		<Rough>
			system tray app
			Open -> Dashboard
			Exit.

			Dashboard
			Graph
			%battery life vs time
			charging
			discharging

			Interested in
			rate of charge
			rate of discharge

			Predicting critical battery time
			Predicting charge time.

			Account for standby interruptions
			Log event of standby on
			Log event of standby resume

			Also note load factor parms
			CPU usage
			Mem load
			HDD activity
			Wifi/Network

			The app itself is less processor and ram intense. Light weight.
			Able to export to excel. CSV.



			Sunday, May 15, 2011 16:15:46 | 85% | Discharging
			Sunday, May 15, 2011 17:14:35 | 59% | Dis




			Saturday, May 14, 2011 23:40:37 | 21% | Charging
			Sunday, May 15, 2011 0:36:47 | 28% Charging

			TODO Simple app to track laoptop battery usage overtime graph
			How fast battery charges back?
			How fast battery discharges?

			App starts on system tray
			%userprofile%\Start Menu\Programs\Startup
			http://www.winxptutor.com/startup.htm

		</Rough>
	</Scenario>
	<Scenario p="2">
		<s>
			The app is already running.
		</s>
		<s>
			System goes to standby mode
		</s>
		<s>
			App logs this event and will show in some conventient way in graph when it comes back.
			<s>
				TBD what convenient way?
			</s>
		</s>
	</Scenario>
	<Scenario p="1" name="Core Algorithm">
		<data>
			<format>
				store xml serialized/deserialized (binary format?)
			</format>
			<structure>
				two arrays one for charging, other for discharging
				for each 0 to 100 (both incusive?) we maintain a array of values with timestamp, duration recorded for this level. e.g.
				<discharge>
					25 -> 5min 32 sec on Tuesday, May 17, 2011 15:27:09 | 4 min 20 sec on Wednesday, May 18, 2011 15:27:55 | 4 min 10 sec on Thursday, May 19, 2011 15:28:19
					26 -> {no data} | 5min 10 EXTRAPOLATED_VALUE
					...
					50 -> 4min 12 sec on Tuesday, May 17, 2011 16:27:09
				</discharge>
				<charge>
					45 -> 8min 10 sec on Tuesday, May 17, 2011 15:27:09 | 4 min 20 sec on Wednesday, May 18, 2011 15:27:55 | 4 min 10 sec on Thursday, May 19, 2011 15:28:19
					47 -> {no data} | 5min 10 EXTRAPOLATED_VALUE
					...
					50 -> 4min 12 sec on Tuesday, May 17, 2011 16:27:09
				</charge>

				Also we will be computing following metrices on top of above
				Average at all level.
				If no data is present, extrapolate. (regression analysis?) liner? exponential? log?
				Computing time left is sum of from current level to 100 (charging) or 0 discharging
				Actual data overrides old extrapolated value.
				Battery degradation coefficient is calculated by rate at which change is detected over a period of time. revisit this assumption

				Predection per level verification and correction
				Say avg at level 40 is 5 min
				But this time actual value was 4 min. Inaccuracy of 1 min detected.
				And avg at level 41 is 4:50
				But this time actual value was 5 min. Inaccuracy of -10sec detected.
					Summing up this value 1+(-10sec) = 50sec
					Avg inaccuracy = 25sec
					
				Algo should strive to reduce this inaccuracy!!!! Revisit this if you can find other patterns to judge algo's inaccuracy?
				

			</structure>
			<computing>
				per level data is computed as following
					if app started == true, wait for level change
					when level is entered for 1st time, timestamp is saved. 
					save this timestamp for beginning of new level and end of old one.
					when level is exited, save timestamp. this is end of current level and beginning of next one. 
						(revist if charge is inverted in between... charg should be same... i.e. if in beginning we were discharguing... we should be continue to do so now also... else observation isn't "pure")
					Once we have a valid data, it is inserted (timespan, starttime, charging state) in existing data structure and things are recalculated.
						Accordingly UI is updated.
			</computing>
		</data>
	</Scenario>
	<Scenario>
		It was observer in raw data analysis that discharge takes about 4.36/2 min per level And recharge takes double of this time.
		One simplified algo can be
		Don't maintain any large historic data.
		Have two numbers d discharge running average time, r recharge running average time.
		time left to recharge fully = r*(1-powerlevel)
		time left to discharge fully = d*powerlevel
		
		pure observation defn:
		1. Same power state throughout the level.
		2. Have power level enter time.
		3. Have power level exit time.
		4. System didn't went to standby or hibernate 
			It works
			
		
		compute timespan. average this with running average
		Running average window = ?? 75? between 100 and 50 or 100??

		Prediction accuracy algo
			Pure observation lies in (avg - stddev) and (avg + stddev)
					stddev. really???
						error margin less than 2 mins overall [ read from config ]
						2*60/100 = 1.2 sec stddev = .6 
						remember also we poll for data so might want to consider this fact 
						above
				success if above is true
				failure if not true.
				success / (success + failure) count [ this is running prediction count] window = 1000?
				<Asserts>
					window of moving avg >= number of elements stored
				</Asserts>
	</Scenario>
	<Scenario>
		The sampling time can be made half of per level time once established.
	</Scenario>
</Scenarios>
